import { stringify } from 'qs';
import {request} from '../utils/request';
import { getConfig } from '../../config';
const config = getConfig();

// 获取备件管理列表--------------------------------------------------------------------
export async function querySparesList(params) {
  return request('/device/deviceattachment/list', {
    method: 'POST',
    body: params,
  });
}


// 设备添加
export async function saveAddSpares(params) {
  return request('/device/deviceattachment/save', {
    method: 'POST',
    body: params,
  });
}

// 备件修改
export async function saveEditSpares(params) {
  return request('/device/deviceattachment/update', {
    method: 'POST',
    body: params,
  });
}


// 设备详情
export async function querySparesInfo(params) {
  if (config.isMock) {
    return request(`/device/deviceattachment/info`, {
      method: 'POST',
      body: params,
    });
  }else{
    return request(`/device/deviceattachment/info/${params.attaId}`, {
      method: 'POST',
    });
  }
}



// 设备（单个）批量操作删除
export async function actionSparesDel(params) {
  return request('/device/deviceattachment/delete', {
    method: 'POST',
    body: params,
  });
}

// 设备 导出
export async function actionSparesExport(params) {
  return request(
    "02200007",
    {
      method: "POST",
      body: params
    },
    null,
    null,
    "download"
  );
}




// 设备批量导入
export async function actionSparesImport(params) {
  return request('02200008', {
    method: 'POST',
    body: params,
  });
}

// 单个备件关联设备查询
export async function queryRelatedEquipment(params) {
  return request('/device/deviceattachment/attaDeviceList', {
    method: 'POST',
    body: params,
  });
}

// 单个备件使用记录查询
export async function querySparesUseRecords(params) {
  return request('/device/deviceattauserecord/list', {
    method: 'POST',
    body: params,
  });
}

// 单个备件操作日志
export async function querySparesOperationlog(params) {
  return request('/device/deviceattacholog/list', {
    method: 'POST',
    body: params,
  });
}
